package com.example.demo11.dem4;

/**
 * @program: demo11
 * @description:
 * @author: 诸葛龙辰
 * @create: 2022-10-31 20:39
 **/
public class People2 implements Runnable{
    private BankCard bankCard;

    public People2(BankCard bankCard) {
        this.bankCard = bankCard;
    }
    @Override
    public void run(){
        for (int i =0;i<10;i++){
            if (bankCard.getBalance()>=1000){
                bankCard.setBalance(bankCard.getBalance()-1000);
                System.out.println(Thread.currentThread().getName()+"向卡中取出1000,卡中余额"+bankCard.getBalance());
            }else {
                System.out.println("余额不足,请存钱");
                i--;
            }
        }
    }
}
